using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Input;

namespace Honest.MES.WPF.Converters
{
    public class WindowStateToCommandConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            // 确保values数组包含两个元素：WindowState和两个ICommand对象
            if (values.Length >= 3 && 
                values[0] is WindowState state && 
                values[1] is ICommand maximizeCommand && 
                values[2] is ICommand restoreCommand)
            {
                // 根据窗口状态返回相应的命令
                return state == WindowState.Maximized ? restoreCommand : maximizeCommand;
            }
            
            // 如果参数无效，默认返回最大化命令
            return values.Length >= 1 && values[1] is ICommand command ? command : null;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}